home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 369 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: theory.lcs.mit.edu!wald
  2. From: wald@theory.lcs.mit.edu (David Wald)
  3. Newsgroups: comp.std.c
  4. Subject: sizeof(char) ~= sizeof(float)
  5. Date: 24 Feb 1996 18:15:32 GMT
  6. Organization: Theory of Computation, LCS, MIT
  7. Message-ID: <WALD.96Feb24131532@woodpecker.lcs.mit.edu>
  8. NNTP-Posting-Host: woodpecker.lcs.mit.edu
  9.  
  10. During a recent recurrence of the perennial "how big is an int"
  11. discussion on comp.lang.c.moderated, I described a freestanding C
  12. implementation I'd dealt with in which, as in some other word-based
  13. implementations, sizeof(char) == sizeof(long) == sizeof(float).
  14. However, one quirk of this architecture was that not all
  15. interpretations of a memory word could see all bits.  In particular,
  16. though integral types and floats each took one word, a float used 8
  17. more bits than the integral types.  When a word was used in integral
  18. operations, the lower 8 bits were invisible and harmless.  Thus you
  19. could have two sections of memory which could be distinguished when
  20. viewed through float*'s but not when viewed through char*'s.
  21.  
  22. Can such an implementation be ANSI-conformant?  The basic argument
  23. against, presented by Tanmoy Bhattacharya, is that memory compare, and
  24. possibly memory copy functions, can't be implemented in a portable
  25. fashion if two dissimilar regions of memory can't be distinguished by
  26. comparing them char-wise.  (I'm unsure about the memory copy, since
  27. I've forgotten whether the implementation actually preserved the
  28. hidden 8 bits when you copied a char.)  Does this violate a constraint
  29. of the standard?  At Tanmoy's suggestion, I'm putting the question
  30. before the collected wisdom comp.std.c.
  31.  
  32. -David
  33.  
  34.  
  35. -- 
  36. ============================================================================
  37. David Wald      http://theory.lcs.mit.edu/~wald/     wald@theory.lcs.mit.edu
  38. ============================================================================
  39.